package practice;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.Reader;
import java.util.*;

public class Practice_1 {
    public static void main(String[] args){
        File file = new File("E:\\javaooGit\\javaooDay22\\src\\practice\\a.txt");
        String s = "";

        try (   FileReader fr = new FileReader(file);
                BufferedReader in = new BufferedReader(fr)){
            String a = "";
            while((a = in.readLine()) != null){
                s += a;
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        Set set = new HashSet();
        char[] chs = s.toCharArray();

        for (int i = 0; i < chs.length; i++) {
            set.add(chs[i]);
        }


        System.out.println(set);
        List list = new ArrayList();
        list.addAll(set);
        System.out.println(list);

        Collections.sort(list, new ListSort());
        System.out.println(list);
    }

    public static String f(String s){
        char[] chs =  s.toCharArray();
        char[] arr = new char[chs.length];
        boolean flag;
        int len = 0;

        for (int i = 0; i < chs.length; i++) {
            flag = true;
            for(int j = 0; j < len; j++){
                if(chs[i] == arr[j]){
                    flag = false;
                    break;
                }
            }

            if(flag){
                arr[len++] = chs[i];
            }
        }

       // System.out.println(arr);
        Character[] arr2 = new Character[arr.length];
        for (int i = 0; i < arr.length; i++) {
            arr2[i] = arr[i];
        }
        Arrays.sort(arr2);

        for (Character character : arr2) {
            System.out.print(character);
        }
        System.out.println();
        return String.valueOf(arr2);
    }
}
